use sha2::Digest;  // 必须导入Digest trait

pub fn calculate_hash(block: &crate::blockchain::Block, nonce: u64) -> String {
    let input = format!(
        "{}{}{:?}{}{}",
        block.index, block.timestamp, 
        block.transactions, block.previous_hash, nonce
    );
    
    // 正确初始化哈希器
    let mut hasher = sha2::Sha256::new();
    hasher.update(input.as_bytes());
    hex::encode(hasher.finalize())
}
